#include <iostream>
#include <map>
#include <set>

struct Student
{
    int id;
    std::string name;
};

int main()
{
#if 0
    std::pair<int, Student> s;
    s.first = 1;
    s.second = {1, "zhangsan"};
#else
    std::pair<int, Student> s = std::make_pair<int, Student>(1,{1,"zhangsan"});
    std::pair<int, Student> s1 = std::make_pair<int, Student>(2,{2,"lisi"});
#endif

    std::map<int, Student> p;
#if 0
    /* insert插入相同键是，如果键已存在，不会插入 */
    p.insert({3,{3,"zhangsan"}});
    p.insert(s);
    p.insert(s1);
#else
    /* 中括号运算符会修改相同键的值 */
    p[1] = {1, "zhangsan"};
    p[2] = {2, "lisi"};
    p[3] = {3, "wangwu"};
    p[1] = {1, "liuzi"};
#endif
    for(auto ite = p.begin(); ite != p.end(); ite++)
    {
        std::cout << ite->first << " " << ite->second.id << " " << ite->second.name << std::endl;
    }

    auto ite = p.find(2);
    std::cout << ite->first << " " << ite->second.id << " " << ite->second.name << std::endl;

    return 0;

}